package com.tomaer.weibo.rss.reader.api;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.tomaer.weibo.rss.reader.WeiboRSSCreator;



public final class WeiboRssReaderServlet extends HttpServlet {
	
	static final long serialVersionUID = -3480032655863237592L;
	static final Log logger = LogFactory.getLog(WeiboRssReaderServlet.class);
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException,IllegalArgumentException{
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException,IllegalArgumentException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
		String weibo = req.getParameter("weibo");
		String certification = req.getParameter("certification");
		String user = req.getParameter("user");
		StringBuilder rss = new StringBuilder();
		rss = WeiboRSSCreator.create(weibo, user, certification);
		System.out.println(rss.toString());
		resp.getWriter().print(rss.toString());
	}
	
}
